package com.ronin.pkimg.control;

import com.ronin.pkimg.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OcrControl {


    @Autowired
    private TaskService taskService;

    @Async
    @GetMapping(value = "/parse")
    public ListenableFuture<String> parseText(@RequestParam("url") String pathUrl, String type) {

        // 可选：设置log4j日志输出格式，若不设置，则使用默认配置
        // 也可以直接通过jvm启动参数设置此环境变量
        // System.setProperty("aip.log4j.conf", "path/to/your/log4j.properties");
        return taskService.execOcrAsyncTask(pathUrl, type);
    }


}
